/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ejb;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.List;
import javax.persistence.Query;
/**
 *
 * @author victor
 */
@Stateless
public class GanadoresFachadaBean implements GanadoresFachadaRemote, GanadoresFachadaLocal {
    @PersistenceContext
    private EntityManager em; 

    public void persist(Object object) {
        em.persist(object);
    }
    public List darGanadores(long idSorteo) {

        Query miConsulta =  em.createNativeQuery("SELECT Usuario.Nick, Usuario.Nombre, Usuario.Apellido FROM Usuario,Ganadores  WHERE Usuario.id = Ganadores.IdUsuario and Ganadores.IdSorteo="+idSorteo);
        List Resultados = null;
        try
        {
            Resultados = miConsulta.getResultList();
        }catch ( Exception e ){ }
         return Resultados;
    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method" or "Web Service > Add Operation")
 
}
